<?php

/**
 * IndexController - The default controller class
 * 
 * @author
 * @version 
 */

require_once 'Zend/Controller/Action.php';

class Adminb_RechargeController extends Zend_Controller_Action 
{
	

	
	public function init(){
		
		$member=new CMember();
		
		if(!$member->isUser($this->_request->getModuleName(),$this->_request->getControllerName())){
			
			if($_COOKIE[COOKIE_PRE.'uid']!=''){
				
				$this->_redirect(MY_URL.'/buyer');
				
			}else{
			
				$this->_redirect(MY_URL.'/buyer-auth-login?preurl=');
				
			}
			
		}
		
	}
	
	public function preDispatch()
	{

		$this->getHelper ('layout')->setLayout('framelayout');
		
		$this->view->addHelperPath(MY_ROOT.'/vhelpers');
		
		Zend_Controller_Action_HelperBroker::addPath(MY_ROOT.'/chelpers');
		
		$this->view->assign('currentAction',$this->_request->getActionName());
			
	}
	

   	public function indexAction(){
   		
   		$virtual=new CVirtual();
   		
   		$virtual_exchange_rate=$virtual->getDetail('virtual_exchange_rate');
    	
    	$this->view->assign('virtual_exchange_rate',$virtual_exchange_rate);
    	
    	$orderid=time().CString::randYzStr(5);
    	
    	$this->view->assign('orderid',$orderid);
    	
    	$this->view->assign('uid',$_COOKIE[COOKIE_PRE.'uid']);
   		
   	}
   	

   	
   	public function dopayAction(){
   		
   		$payment=$this->_request->getParam('payment');
   		
   		$amount=$this->_request->getParam('amount');
   		
   		$item_name=$this->_request->getParam('item_name');
  			
  		$account=new CAccount();
				
		$data=array(
					'should_paid'=>$amount,
					'has_paid'=>0,
					'flid'=>6,
					'state'=>0,
					'orderid_string'=>'',
					'from_uid'=>$_COOKIE[COOKIE_PRE.'uid'],
					'to_uid'=>0,
					'add_time'=>time(),
					'payment'=>$payment,
					'remark'=>''
					);
		
		$account->createAccount($data);
		
		$this->view->assign('item_name',$item_name);
		
		$this->view->assign('amount',$amount);
		
		$this->render('dopay-'.$payment);
   		
   	}

	
	public function postAction(){
	
		//$this->_helper->viewRenderer->setNoRender();
		
		//$this->getHelper ('layout')->disableLayout ();
	
	}
    

    
}
